{% extends 'base_authed.html' %}

{% block title %}收件箱{% endblock %}
{% block js %}
<script type="text/javascript">
	function deleteMessage(msgId){
		if(confirm('您确定要删除该消息吗？')){
			new Request({url: '/inbox/delmessage/' + msgId + '/', onSuccess: function(responseText){
				if(responseText){
					location.href = '/inbox/';
				}
				else{
					alert('删除消息失败！');
				}
			}}).send();
		}
	}
</script>
{% endblock %}

{% block content %}
<div>
	<div>
		<span style="border:solid 1px #333">
			<a href="/inbox/">收件箱</a> | 发件箱
		</span>
		<span style="border:solid 1px #333;margin-left:800px"><a href="/inbox/sendmessage/">写消息</a></span>
	</div>
	<table>
		<tr>
			<td colspan="2" style="text-align:center">
				{{ message.title }}
				<hr />
			</td>
		</tr>
		<tr>
			<td>
				<img src="{{ message.sender.get_profile.logo }}" style="float:left" />
				<div>
					{{ message.sender.get_full_name }}
					<br />
					{{ message.post_time|date:"Y-m-d H:i" }}
				</div>
			</td>
			<td>
				{{ message.content}}
				<hr />
				<div>标记为未读 | <a href="javascript:deleteMessage({{ message.id }})">删除</a></div>
			</td>
		</tr>
	</table>
</div>
{% endblock %}